<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security" %>
<LINK href="images/css.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
.STYLE1 {
	font-size: 12px
}

.STYLE3 {
	color: #707070;
	font-size: 12px;
}

.STYLE5 {
	color: #0a6e0c;
	font-size: 12px;
}

body {
	margin-top: 0px;
	margin-bottom: 0px;
}

.STYLE7 {
	font-size: 12
}
 div{
    width:50%;
    height:50%;
    color:#0a6e0c;
    margin-top:50px;
 }
 #left{
    float:left;
 }
 #right{
    float:right;
 }
-->
</style>
<script type="text/javascript">
	function checkForm() {
		var buildingId = document.getElementById("houseId").value;
		var name = document.getElementById("name").value;
		var type = document.getElementById("houseTypeId").value;
		var houseSource = document.getElementById("houseSource").value;
		var houseUnit = document.getElementById("houseUnit").value;
		var houseFloor = document.getElementById("houseFloor").value;
		var houseBuilding = document.getElementById("buildingId").value;
		var houseOwner = document.getElementById("houseOwner").value;
		
		

		if (houseId == 0) {
			alert("请输入房产编号！");
			return false;
		}
		if (name == 0) {
			alert("请输入房产名称！");
			return false;
		}
		if (type == 0) {
			alert("请输入房产类型！");
			return false;
		}
		if (houseSource == 0) {
			alert("请输入房产来源！");
			return false;
		}
		if(houseUnit == 0){
			alert("请输入房产所处的单元");
			return false;
		}
		if(houseFloor == 0){
			alert("请输入房产所处的楼层");
			return false;
		}
		if(houseBuilding==0){
			alert("请输入房产所处的楼栋 ");
			return false;
		}
		if(houseOwner==0){
			alert("请输入房产的业主 ");
			return false;
		}
	}
	var req;
	
	function init() {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	//根据小区ID查询DropChangeAJAXAction，获得该小区的楼栋列表
	function changeDropOfBuilding() {
		init();
		
		var url="dropChangeAJAX.do?method=changeDropOfBuilding&subId="+escape(document.forms[0].subId.options[document.forms[0].subId.selectedIndex].value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	
	function callback() {
		if (4 == req.readyState) {
			if (200 == req.status) {
				eval(req.responseText);
			}
		}
	}
</script>
<html:form action="house.do?method=updateSave" method="post" onsubmit="return checkForm();">
  

   <table class="tableline" cellspacing="1" cellpadding="0" width="100%" border="0">
  <html:hidden property="id" value="${house.id}" />
    <tr>
      <td class="STYLE4" colspan="2" height="30" align="center" bgcolor="#ffffff">修改房产信息</td>
    </tr>
    <tr>
      <td width="230" height="26" align="right" bgcolor="#ffffff">房产编号：</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="houseId" value="${house.houseId }" />
							<font color="red">${houseIdError }</font></td>
    </tr>
    <tr>
      <td height="26" align="right" bgcolor="#ffffff">房产名称：</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="name" value="${house.name }" />
							
      </td>
    </tr>
    <tr>
      <td height="26" align="right" bgcolor="#ffffff">房屋类型：</td>
      <td width="773" bgcolor="#ffffff">&nbsp;<html:select property="houseTypeId" style="width:159px;">
				
				<c:if test="${!empty houseTypeList}">
					<c:forEach items="${houseTypeList}" var="houseType">
					    <html:option value="${houseType.id}">${houseType.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select><font color="red">${houseTypeError }</font>
	 </td>
    </tr>
    
    <tr>
      <td height="26" align="right" bgcolor="#ffffff">房产来源 ：</td>
      <td width="773" bgcolor="#ffffff">
				&nbsp;<html:select property="houseSourceId" style="width:159px">
				<c:if test="${!empty houseSourceList}">
					<c:forEach items="${houseSourceList}" var="houseSource">
						<html:option value="${houseSource.id}">${houseSource.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select>&nbsp;<font color="red">${houseSourceError }</font>
			</td>
    </tr>
    
     <tr>
      <td height="26" align="right" bgcolor="#ffffff">房产面积：</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="area" value="${house.area }" />
							
      </td>
    </tr>
    
    <tr>
      <td height="26" align="right" bgcolor="#ffffff">所处单元：</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="unit" value="${house.unit }" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入1位数字</span>
      </td>
    </tr>
    
        <tr>
      <td height="26" align="right" bgcolor="#ffffff">所在楼层：</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="floor" value="${house.floor }" />
							
      </td>
    </tr>
    
    <tr>
	<td width="217" height="26" align="right" bgcolor="#ffffff">物业服务处：</td>
	<td width="773" bgcolor="#ffffff">
	&nbsp;<html:select property="districtId"  style="width:159px" value="${house.building.subDistrict.district.id}">
			<html:option value="0">请选择</html:option>
			<c:if test="${!empty districtList}">
				<c:forEach items="${districtList}" var="district">
					<html:option value="${district.id}">${district.name}</html:option>
				</c:forEach>
			</c:if>
		</html:select>&nbsp;<font color = "red">${districtIdError }</font>
	</td>
</tr>
<tr>
<td width="217" height="26" align="right" bgcolor="#ffffff">所属小区：</td>
<td width="773" bgcolor="#ffffff">
	&nbsp;<html:select property="subId"  style="width:159px" onchange="changeDropOfBuilding()" value="${house.building.subDistrict.id}">
		<html:option value="0">请选择</html:option>
		<c:if test="${!empty subList}">
			<c:forEach items="${subList}" var="sub">
				<html:option value="${sub.id}">${sub.name}</html:option>
			</c:forEach>
		</c:if>
	</html:select>&nbsp;
	<font color = "red">${houseSubIdError }</font>
</td>
</tr>
    
     <tr>
      <td height="26" align="right" bgcolor="#ffffff">所属楼栋：</td>
       <td width="773" bgcolor="#ffffff">
       &nbsp;<html:select property="buildingId" style="width:159px"  value="${house.building.id}" >
				<c:if test="${!empty houseBuildingList}">
					<c:forEach items="${houseBuildingList}" var="building">
						<html:option value="${building.id}">${building.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select>
		   
      </td>
    </tr>
    
      <tr>
	      <td width="230" height="26" align="right" bgcolor="#ffffff">业主姓名：</td>
	      <td bgcolor="#ffffff">&nbsp;<html:text property="ownerName" value="${owner.name }" />
								<font color="red">${houseownerError }</font></td>
       </tr>
       
       <tr>
         <td width = "230" height = "26" align = "right" bgcolor = "#ffffff">工作单位：</td>
         <td bgcolor="#ffffff">&nbsp;<html:text property="workUnit" value="${owner.workUnit}" />
								</td>
       </tr>
       
        <tr>
         <td width = "230" height = "26" align = "right" bgcolor = "#ffffff">身份证：</td>
         <td bgcolor="#ffffff">&nbsp;<html:text property="idCard" value="${owner.idCard}" />
								</td>
       </tr>
       
        <tr>
         <td width = "230" height = "26" align = "right" bgcolor = "#ffffff">联系电话：</td>
         <td bgcolor="#ffffff">&nbsp;<html:text property="phone" value="${owner.phone}" />
								</td>
       </tr>
       
       <tr>
         <td width = "230" height = "26" align = "right" bgcolor = "#ffffff">家庭成员姓名：</td>
         <td bgcolor="#ffffff">&nbsp;<html:text property="fmName" value="${owner.fmName}" />
								</td>
       </tr>
       
       <tr>
         <td width = "230" height = "26" align = "right" bgcolor = "#ffffff">家庭成员电话：</td>
         <td bgcolor="#ffffff">&nbsp;<html:text property="fmPhone" value="${owner.fmPhone}" />
								</td>
       </tr>
       
       <tr>
         <td width = "230" height = "26" align = "right" bgcolor = "#ffffff">家庭成员身份证：</td>
         <td bgcolor="#ffffff">&nbsp;<html:text property="fmIdCard" value="${owner.fmIdCard}" />
         <html:submit value="确认修改" />
								</td>
       </tr>
  </table> 

  </html:form>